The disclosed embodiments of the present invention relate to a loading calculation method and a loading calculation system, and more particularly, to a loading calculation method and a loading calculation system capable of precisely calculating the loading of the processor by detecting the switching actions of the processor and the log file thereof.
In general, a conventional loading calculation method for a CPU in an electronic device (such as a smartphone, a tablet, a laptop, a PC, or a handheld computing device) uses the sampling method. For example, the conventional loading calculation method uses the global variable jiffies in the Linux Kernel to record the number of ticks that have occurred since the system booted, wherein ticks is equal to 1/Hz. For example, when Hz=100, ticks=0.01 or 10 micro seconds.
When a higher loading calculating precision is required, Hz has to be higher. For example, when Hz is raised from 100 to 1000, the loading calculating precision will be 10 times higher. However, since the value of Hz determines the number of timer interrupts, a higher value of Hz means that the CPU has to process more timer interrupts. Thus, the conventional loading calculation method has problems of causing additional loading to the CPU when higher loading calculating precision is required.